﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Sortable.Default" %>

<%@ Register Assembly="Sortable" Namespace="Sortable" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Sortable Test Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>" 
            SelectCommand="SELECT [BusinessEntityID] AS [Id], [Title], [FirstName], [LastName] FROM [Person].[Person]" />
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            SelectMethod="Select" SelectCountMethod="SelectCount" TypeName="Sortable.PersonDataSource" EnablePaging="True" 
            SortParameterName="sortExpression"  />
        <table>
            <tr>
                <th>&nbsp;</th>
                <th>Original Asp.Net</th>
                <th>Extended Controls</th>
            </tr>
            <tr>
                <th>ListView</th>
                <td>   
                    <asp:ListView ID="ListView1" runat="server" DataKeyNames="Id" DataSourceID="ObjectDataSource1">
                       <ItemTemplate>
                            <tr>
                                <td>
                                    <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("FirstName") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="LastNameLabel" runat="server" Text='<%# Eval("LastName") %>' />
                                </td>
                            </tr>
                        </ItemTemplate>
                        <LayoutTemplate>
                            <table id="Table1" runat="server">
                                <tr id="Tr1" runat="server">
                                    <td id="Td1" runat="server">
                                        <table ID="itemPlaceholderContainer" runat="server" border="0" rules="all" style="border:1px solid black">
                                                <tr id="Tr2" runat="server">
                                                    <th id="Th1" runat="server">
                                                        <cc1:SorterHyperLink runat="server" ID="SorterHyperLink1" Text="Title" Expression="Title" QueryStringField="Sort1" />
                                                    </th>
                                                    <th id="Th2" runat="server">
                                                        <cc1:SorterHyperLink runat="server" ID="SorterHyperLink2" Text="FirstName" Expression="FirstName" QueryStringField="Sort1" />
                                                    </th>
                                                    <th id="Th3" runat="server">
                                                        <cc1:SorterHyperLink runat="server" ID="SorterHyperLink3" Text="LastName" Expression="LastName" QueryStringField="Sort1" />
                                                    </th>
                                                </tr>
                                            <tr ID="itemPlaceholder" runat="server">
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr id="Tr3" runat="server">
                                    <td id="Td2" runat="server">
                                    </td>
                                </tr>
                            </table>
                        </LayoutTemplate>
                    </asp:ListView>
                    <asp:DataPager ID="DataPager1" runat="server" QueryStringField="Page1" PagedControlID="ListView1">
                        <Fields>
                            <asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                            <asp:NumericPagerField />
                            <asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                        </Fields>
                    </asp:DataPager>
                </td>
                <td>
                    <cc1:ListViewEx ID="ListViewEx1" runat="server" DataKeyNames="Id" DataSourceID="ObjectDataSource1">
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("FirstName") %>' />
                                </td>
                                <td>
                                    <asp:Label ID="LastNameLabel" runat="server" Text='<%# Eval("LastName") %>' />
                                </td>
                            </tr>
                        </ItemTemplate>
                        <LayoutTemplate>
                            <table id="Table1" runat="server">
                                <tr id="Tr1" runat="server">
                                    <td id="Td1" runat="server">
                                        <table ID="itemPlaceholderContainer" runat="server" border="0" rules="all" style="border:1px solid black">
                                                <tr id="Tr2" runat="server">
                                                    <th id="Th1" runat="server">
                                                        <cc1:SorterHyperLink runat="server" ID="SorterHyperLink1" Text="Title" Expression="Title" QueryStringField="Sort2" />
                                                    </th>
                                                    <th id="Th2" runat="server">
                                                        <cc1:SorterHyperLink runat="server" ID="SorterHyperLink2" Text="FirstName" Expression="FirstName" QueryStringField="Sort2" />
                                                    </th>
                                                    <th id="Th3" runat="server">
                                                        <cc1:SorterHyperLink runat="server" ID="SorterHyperLink3" Text="LastName" Expression="LastName" QueryStringField="Sort2" />
                                                    </th>
                                                </tr>
                                            <tr ID="itemPlaceholder" runat="server">
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr id="Tr3" runat="server">
                                    <td id="Td2" runat="server">
                                    </td>
                                </tr>
                            </table>
                        </LayoutTemplate>
                    </cc1:ListViewEx>
                    <asp:DataPager ID="DataPager2" runat="server" QueryStringField="Page2" PagedControlID="ListViewEx1">
                        <Fields>
                            <asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                            <asp:NumericPagerField />
                            <asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                        </Fields>
                    </asp:DataPager>
                </td>
            </tr>
            <tr>
                <th>GridView</th>
                <td>
                    <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" 
                        AutoGenerateColumns="False" DataKeyNames="Id" AllowPaging="True">
                        <Columns> 
                            <asp:TemplateField HeaderText="Title" SortExpression="Title">
                                <HeaderTemplate>
                                    <cc1:SorterHyperLink runat="server" ID="SorterHyperLink1" Text="Title" Expression="Title" QueryStringField="Sort3" />
                                </HeaderTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="FirstName" SortExpression="FirstName">
                                <HeaderTemplate>
                                    <cc1:SorterHyperLink runat="server" ID="SorterHyperLink2" Text="FirstName" Expression="FirstName" QueryStringField="Sort3" />
                                </HeaderTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="LastName" SortExpression="LastName">
                                <HeaderTemplate>
                                    <cc1:SorterHyperLink runat="server" ID="SorterHyperLink3" Text="LastName" Expression="LastName" QueryStringField="Sort3" />
                                </HeaderTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </td>
                <td>
                    <cc1:GridViewEx ID="GridViewEx1" runat="server" DataSourceID="ObjectDataSource1" 
                        AutoGenerateColumns="False" DataKeyNames="Id" AllowPaging="True" 
                        HidePager="True">
                        <Columns>
                            <asp:TemplateField HeaderText="Title" SortExpression="Title">
                                <HeaderTemplate>
                                    <cc1:SorterHyperLink runat="server" ID="SorterHyperLink1" Text="Title" Expression="Title" QueryStringField="Sort4" />
                                </HeaderTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="FirstName" SortExpression="FirstName">
                                <HeaderTemplate>
                                    <cc1:SorterHyperLink runat="server" ID="SorterHyperLink2" Text="FirstName" Expression="FirstName" QueryStringField="Sort4" />
                                </HeaderTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="LastName" SortExpression="LastName">
                                <HeaderTemplate>
                                    <cc1:SorterHyperLink runat="server" ID="SorterHyperLink3" Text="LastName" Expression="LastName" QueryStringField="Sort4" />
                                </HeaderTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </cc1:GridViewEx>
                    <asp:DataPager ID="DataPager4" runat="server" PagedControlID="GridViewEx1" QueryStringField="Page4">
                        <Fields>
                            <asp:NextPreviousPagerField ShowFirstPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                            <asp:NumericPagerField />
                            <asp:NextPreviousPagerField ShowLastPageButton="True" 
                                ShowNextPageButton="False" ShowPreviousPageButton="False" />
                        </Fields>
                    </asp:DataPager>
                </td>
            </tr>
        </table>
        <br />
    </form>
    
</body>
</html>
